home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / FLI106C.ZIP;1 / DIAFLOAT.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-12  |  1.8 KB  |  90 lines

  1. //
  2. // The Fusion Library Interface for DOS
  3. // Version 1.06c
  4. // Copyright (C) 1990, 1991, 1992
  5. // Software Dimensions
  6. //
  7. // DialogClass
  8. // DiaFloat
  9. //
  10.  
  11. #include "fli.h"
  12. #include "elements.h"
  13. #include "colors.h"
  14.  
  15. #ifdef __BCPLUSPLUS__
  16. #pragma hdrstop
  17. #endif
  18.  
  19. #include <string.h>
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22.  
  23. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  24. //
  25. // DiaFloat()
  26. //
  27. // Constructor
  28. //
  29. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  30.  
  31. DiaFloat::DiaFloat(int _X,int _Y,char *_Mask,float &_Value,int _NoEditErase) :
  32.   Numerics(_NoEditErase), Value(_Value)
  33. {
  34.   X=_X;
  35.   Y=_Y;
  36.   Mask=_Mask;
  37.   Width=strlen(Mask);
  38.   Height=1;
  39.  
  40.   AllowedAfterDecimal=0;
  41.  
  42.   if (strpbrk(Mask,"-+("))
  43.     AllowedNegative++;
  44.  
  45.   CountPlaces(Mask,AllowedBeforeDecimal,AllowedAfterDecimal);
  46.  
  47.   Numerics::Value=new char[40];
  48.   sprintf(Numerics::Value,"%-*.*f",AllowedBeforeDecimal,AllowedAfterDecimal,Value);
  49.   TrimTrailingZeros();
  50. }
  51.  
  52. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  53. //
  54. // Show()
  55. //
  56. // Show the element
  57. //
  58. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  59.  
  60. void DiaFloat::Show()
  61. {
  62.   if (atof(Numerics::Value)!=Value)
  63.   {
  64.     sprintf(Numerics::Value,"%-*.*f",AllowedBeforeDecimal,AllowedAfterDecimal,Value);
  65.     TrimTrailingZeros();
  66.   }
  67.  
  68.   Numerics::Show();
  69. }
  70.  
  71. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  72. //
  73. // EventHandler()
  74. //
  75. // Handles the events
  76. //
  77. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  78.  
  79. int DiaFloat::EventHandler(int Event)
  80. {
  81.   int ReturnEvent=EventValidation(Event);
  82.  
  83.   if (ReturnEvent==CompleteEvent)
  84.     Value=atof(Numerics::Value);
  85.  
  86.   HighLight();
  87.  
  88.   return ReturnEvent;
  89. }
  90.